package controllers

import (
	"myblog/utils"

	beego "github.com/beego/beego/v2/server/web"
)

type ViewController struct {
	beego.Controller
}

func (this *ViewController) Get() {
	file := this.Ctx.Input.Param(":splat")
	//获取目录文件名
	postdir, _ := beego.AppConfig.String("postdir")
	postdir = utils.GetCurrentPath() + postdir

	file = postdir + file
	// fmt.Println(file)
	title, _, _ := utils.ReadFileTile("/" + file)
	content := utils.ReadFile("/" + file)
	this.Data["ViewTitle"] = title
	this.Data["ViewContent"] = content
	this.TplName = "model/view.tpl"
	this.LayoutSections = make(map[string]string)
	this.LayoutSections["IndexHead"] = "model/vhead.tpl"
	this.LayoutSections["IndexNavbar"] = "model/navbar.tpl"
	this.LayoutSections["IndexNav"] = "model/nav.tpl"
	this.LayoutSections["IndexFoot"] = "model/vfoot.tpl"
	this.Layout = "index.tpl"

}
